package com.candy.service.impl;

import com.candy.dao.AccountDao;
import com.candy.service.AccountService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 转账操作；Transactional注解用于事务管理
 */
@Transactional
public class AccountServiceImpl implements AccountService {
    private AccountDao accountDao;

    /**
     * 转账操作
     * @param outterUser 转账人信息（扣款账户）
     * @param innerUser  被转账人信息（新增收入账户）
     * @param money 转账金额
     */
    @Override
//    @Transactional
    public void saveAccount(String outterUser, String innerUser, Integer money) {
        accountDao.subAccount(outterUser,money);
//        System.out.println(9/0);
        accountDao.addAccount(innerUser,money);

    }

    public AccountDao getAccountDao() {
        return accountDao;
    }

    public void setAccountDao(AccountDao accountDao) {
        this.accountDao = accountDao;
    }
}
